<?
include '../includes/specs_functions.php';

#----------------------------------------------------
# Connect to PADS
$DB = getDB();

$specId = $_POST['specId'];

$level = 50; // Max level ignore all other skills

	$table = "(".SPEC_TBL_COMPONENTS." as comp
			LEFT JOIN 
			".TBL_ABILITIES." as ab
			ON ab.".TBL_ABILITIES_ID." = comp.".SPEC_TBL_COMPONENTS_SKILL_ID.")";
	$col = array(
			"ab.".TBL_ABILITIES_ENNAME." as name"
			,"ab.".TBL_ABILITIES_LEVEL." as level"
			,"ab.".TBL_ABILITIES_ID." as id"
			,"ab.".TBL_ABILITIES_MP." as mp"
			,"ab.".TBL_ABILITIES_HP." as hp"
			,"ab.".TBL_ABILITIES_TP." as tp"
			,"ab.".TBL_ABILITIES_CASTTIME." as cast"
			,"ab.".TBL_ABILITIES_RECASTTIME." as recast"
			,"ab.".TBL_ABILITIES_RANGE." as range"
			,"ab.".TBL_ABILITIES_ICON." as icon"
			,"ab.".TBL_ABILITIES_ENDESC." as description"
			,"comp.".SPEC_TBL_COMPONENTS_POSITION." as pos"
			,"comp.".SPEC_TBL_COMPONENTS_TEMPLATE." as template"
			);

		   
	$where = array(
				"comp.".SPEC_TBL_COMPONENTS_SPEC_ID." = \"".$specId."\""
				);
	$orderBy = "ab.".TBL_ABILITIES_LEVEL;
	$direction = "ASC";
	
	
	$result = $DB->GetData($table ,$col ,true ,$where, $orderBy, $direction);
	//Show($result);
	
	//Show($result);
	
	$jobs = array();
	if($result[0]){
		foreach ($result[3] as $row) {
				
			$job = array( 
							"id" => $row['id']
							,"name" => $row['name']
							,"level" => $row['level']
							,"mp" => $row['mp']
							,"hp" => $row['hp']
							,"tp" => $row['tp']
							,"cast" => $row['cast']
							,"recast" => $row['recast']
							,"range" => $row['range']
							,"icon" => $row['icon']
							,"desc" => $row['description']
							,"type" => "skill"
							,"pos" => $row['pos']
							,"template" => $row['template']
						);
			array_push($jobs, $job);
		}
	}
	
echo json_encode($jobs);
	
#------------------------------------------------------------------------
# Disconnect
leaveDB($DB);


?>